<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8" /> 
	<title>Study React</title>
	<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
	<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
	<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>

<body>
    完成功能需求：一个用户名、密码登陆框
	<div id="example"></div>

	<script type="text/babel">
        class Demo extends React.Component {
            submitForm = (e)=> {
                e.preventDefault();
                alert(`用户名：${this.input.value}, 密码：${this.password.value}`);
            }

            render() {
                return (
                    // form有个默认的属性action, <form action , 跳转地址, 而且还会自动清空表单数据
                    // 感觉有点跟不上潮流时代了，多此一举；现在的都是ajax，不想页面刷新
                    <form onSubmit={this.submitForm} action="/service/sub">
                        用户名：<input type="text" ref={element => this.input=element} />
                        密码: <input type="password" ref={element => this.password=element} />
                        <button>submit</button>
                    </form>
                );
            }
        }
        
		ReactDOM.render(<Demo />, document.getElementById('example'));
	</script>

</body>

</html>